#!/usr/bin/python
# -*- coding:UTF8 -*-
# pytest实现数据驱动
import pytest


@pytest.mark.parametrize("x,y", [(1, 1), (1, 2), (2, 1), (3, 2), (6, 1)])
def test(x, y):
    assert x > y


test1 = ("", "helloworld", "ask", "xxxxxxxx", 401, "错误的accessToken")
test2 = ("eb13d528-667a-4111-9905-5df1c08f1b17", "", "ask", "xxxxxxxx", 400, "标题不能为空")
test3 = ("eb13d528-667a-4111-9905-5df1c08f1b17", "ddddddddddddd", "", "xxxxxxxx", 400, "必须选择一个版块")
test4 = ("eb13d528-667a-4111-9905-5df1c08f1b17", "ddddddddddddd", "ask", "", 400, "内容不可为空")


@pytest.mark.parametrize('token,title,tab,content,except_result_code,except_error_msg', [test1, test2, test3, test4])
def test_topic(token, title, tab, content, except_result_code, except_error_msg, tapi=None):
    r = tapi.create_topic(token, title, tab, content,except_result_code)
    print(r.json(), r.except_result_code)
    # 断言状态码
    assert 401 == r.except_result_code
    # # 错误信息判断
    assert 400 == r.except_error_msg
# 添加测试报告


